package quickstart.workbench

import groovy.transform.CompileStatic
import javafx.event.Event
import javafx.scene.Node
import javafx.scene.control.Menu
import javafx.stage.Stage
import javafx.stage.StageStyle
import org.jacpfx.api.annotations.Resource
import org.jacpfx.api.annotations.workbench.Workbench
import org.jacpfx.api.componentLayout.WorkbenchLayout
import org.jacpfx.api.message.Message
import org.jacpfx.api.util.ToolbarPosition
import org.jacpfx.rcp.componentLayout.FXComponentLayout
import org.jacpfx.rcp.context.Context
import org.jacpfx.rcp.workbench.FXWorkbench

import static quickstart.config.BasicConfig.PERSPECTIVE_ONE

/**
 * Created by TK-chenbin on 2015/5/20.
 */
@CompileStatic
@Workbench(id = "wb01", name = "workbench",
        perspectives = [PERSPECTIVE_ONE])
class JacpFXWorkbench implements FXWorkbench {
    @Resource
    private Context context

    @Override
    void handleInitialLayout(final Message<Event, Object> action,
                             final WorkbenchLayout<Node> layout,
                             final Stage stage) {
        layout.setWorkbenchXYSize(1024, 600)
        layout.registerToolBar(ToolbarPosition.NORTH)
        layout.style = StageStyle.DECORATED
        layout.menuEnabled = true
    }

    @Override
    void postHandle(final FXComponentLayout layout) {
        layout.getMenu().registerWindowButtons()
        layout.getMenu().menus << new Menu("File")
    }
}
